********************************************************************************
*Author: Elizabeth Dorssom
*REPLICATION FILES FOR "Does Legislative Institutionalization Impact Policy 
				//Adoption? New Evidence from the Colonial and Early State 
				// Legislatures 1757�1795"
*Stata Version 13.1
*Date Created: 04/11/2021
*Date Edited: 04/11/2021
********************************************************************************
********************************************************************************
*								DROP VARIABLES								   *
********************************************************************************
********************************************************************************

*DROP YEARS 1770-1777

drop if year == 1770
drop if year == 1771
drop if year == 1772 
drop if year == 1773 
drop if year == 1774 
drop if year == 1775 
drop if year == 1776
drop if year == 1777
 
 
*DROP DUPLICATE DATA
 duplicates tag colony year, generate(year_dup)
 duplicates drop colony year, force

********************************************************************************
* 					AVERAGE SUNSET PROVISIONS GRAPH							   *
********************************************************************************

*CHANGE POPULATION VARIABLE FOR REGRESSION
gen pop = (population/1000)

*GENERATE NEW SUNSET RATE VARIABLE FOR GRAPHS
gen Sunset_Rate = (sunset_total/totallaws)*100

*GENERATE NEW VARIABLE FIRST
egen Sunset_Rate2 = mean(Sunset_Rate), by(year)

*GENERATE NEW VARIABLE OF AVERAGE SUNSET PROVISION USE BY YEAR
egen Sun_Tot = mean (sunset_total), by(year)

*GENERATE NEW VARIABLE DIVIDING EACH S.P. SUBTYPE BY TOTAL S.P. BY YEAR)
gen ExactTime = (exact_time/Sun_Tot)*100

*GENERATE NEW AVERAGE VARIABLE FOR GRAPH
egen Exact_Time2 = mean(ExactTime), by(year)
********************************************************************************
********************************************************************************
* 			FIGURE 1 Sunset Provision Rate, 1757�1770 and 1775�1795			   *
********************************************************************************
********************************************************************************
 gr tw (connected Sun_Tot year if year<=1769, name(g1, replace) nodraw)
 gr tw (connected Sun_Tot year if year>=1778, name(g2, replace) nodraw)
 graph combine g1 g2, ycommon name(combined, replace)
 graph display combined, xsize(10)

********************************************************************************
 *GENERATE NEW VARIABLE
gen WarEnd = (war_end/Sun_Tot)*100
 *GENERATE NEW VARIABLE FIRST
egen War_End = mean(WarEnd), by(year)


*GENERATE NEW VARIABLE 
 gen NatCong = (nat_cong/Sun_Tot)*100
  *GENERATE NEW VARIABLE 
egen Nat_Cong = mean(NatCong), by(year)

*GENERATE NEW VARIABLE 
 gen NonSpec = (non_spec/Sun_Tot)*100
   *GENERATE NEW VARIABLE 
egen Non_Spec = mean(NonSpec), by(year)

*GENERATE NEW VARIABLE 
 gen NextMtg = (next_mtg/Sun_Tot)*100
    *GENERATE NEW VARIABLE FIRST
egen Next_Mtg = mean(NextMtg), by(year)

 
 
********************************************************************************
********************************************************************************
* 			FIGURE 2 Sunset Rate Across Expiration Terms, 1757�1795		       *
********************************************************************************
********************************************************************************
 
*COMBINED GRAPHs 1757-1770 & 1771-1795 

gr tw (connected Exact_Time2 year if year<1770, nodraw name(g1, replace)) 
gr tw (connected Exact_Time2 year if year>1777, nodraw name(g2, replace)) 
gr tw (connected Next_Mtg year if year<1770, nodraw name(g3, replace)) 
gr tw (connected Next_Mtg year if year>1777, nodraw name(g4, replace)) 
gr tw (connected Non_Spec year if year<1770, nodraw name(g5, replace)) 
gr tw (connected Non_Spec year if year>1777, nodraw name(g6, replace))
gr tw (connected War_End year if year<1770, nodraw name(g7, replace)) 
gr tw (connected War_End year if year>1777, nodraw name(g8, replace))

graph combine g1 g2 g3 g4 g5 g6 g7 g8, ycommon name(combined, replace)
graph display combined, xsize(10)


********************************************************************************
********************************************************************************
*				FIGURE 3: Total Laws Passed, 1757�1770 and 1775�1795						   *
********************************************************************************
********************************************************************************




gen state=.

replace state=0 if year>1756 & year<1777

replace state=1 if year>1776 & year<1796

*below just checks to see if this is what you want

table year state, missing

label define timeperiod 0 "Colony" 1 "State"

label values state timeperiod

graph bar totallaws, over(year, label(angle(vertical))) over(state) nofill ytitle("# of Laws Passed Per Year")



******************************************************************************** 
********************************************************************************
*	FIGURE 4: Sunset Provision Rate In Massachusetts Bay And Virginia, 1757�1795										   *
********************************************************************************
********************************************************************************
		
*COMBINED VIRGINIA AND MASSACHUSETTS GRAPHS
gr tw (connected Sunset_Rate year if colony=="MA", name(g1, replace) nodraw)
gr tw (connected Sunset_Rate year if colony=="VA", name(g2, replace) nodraw)
graph combine g1 g2, ycommon name(combined, replace)
		
******************************************************************************** 
********************************************************************************
*	FIGURE 5: Sunset Provision Rate in Massachusetts Bay and Virginia 
			// Across Expiration Terms, 1757�1795										   *
********************************************************************************
********************************************************************************

*COMBINED VIRGINIA AND MASSACHUSETTS GRAPHS 
gr tw (connected ExactTime year if colony=="MA", nodraw name(g1, replace)) 
gr tw (connected ExactTime year if colony=="VA", nodraw name(g2, replace)) 
gr tw (connected NextMtg year if colony=="MA", nodraw name(g3, replace)) 
gr tw (connected NextMtg year if colony=="VA", nodraw name(g4, replace)) 
gr tw (connected NonSpec year if colony=="MA", nodraw name(g5, replace)) 
gr tw (connected NonSpec year if colony=="VA", nodraw name(g6, replace))
gr tw (connected WarEnd year if colony=="MA", nodraw name(g7, replace)) 
gr tw (connected WarEnd year if colony=="VA", nodraw name(g8, replace))

graph combine g1 g2 g3 g4 g5 g6 g7 g8, ycommon name(combined, replace)
graph display combined, xsize(10)

********************************************************************************
********************************************************************************
********************************************************************************
*				FRACTIONAL LOGIT REGRESSION									   *
********************************************************************************
********************************************************************************

*Fractional Logit Model
fracreg logit Sunset_Rate leg_type leg_pay pop upperhouse_elected totallaws



